<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="计件年月" prop="jjYm">
        <el-date-picker clearable
          v-model="queryParams.jjYm"
          type="month"
          value-format="yyyy-MM"
          placeholder="请选择计件年月">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="工号" prop="jobNo">
        <el-input
          v-model="queryParams.jobNo"
          placeholder="请输入工号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['hr:rePunAssess:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hr:rePunAssess:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hr:rePunAssess:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hr:rePunAssess:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="rePunAssessList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="计件年月" align="center" prop="jjYm" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jjYm, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="公司名称" align="center" prop="factoryName" width="120"/>
      <el-table-column label="工号" align="center" prop="jobNo" width="140"/>
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="部门" align="center" prop="department" />
      <el-table-column label="分部" align="center" prop="branch" />
      <el-table-column label="班组" align="center" prop="team" />
      <el-table-column label="岗位" align="center" prop="jobs" />
      <el-table-column label="奖惩项目" align="center" prop="rePunProject" />
      <el-table-column label="奖惩小项" align="center" prop="rePunPro" />
      <el-table-column label="奖惩标准" align="center" prop="rePunStandard" />
      <el-table-column width="120" label="部门奖惩标准" align="center" prop="bmRePunStandard" />
      <el-table-column width="120" label="分部奖惩标准" align="center" prop="fbRePunStandard" />
      <el-table-column width="120" label="车间奖惩标准" align="center" prop="cjRePunStandard" />
      <el-table-column width="120" label="班组奖惩标准" align="center" prop="bzRePunStandard" />
      <el-table-column width="120" label="1日奖惩数量" align="center" prop="rpNum1" />
      <el-table-column width="120" label="2日奖惩数量" align="center" prop="rpNum2" />
      <el-table-column width="120" label="3日奖惩数量" align="center" prop="rpNum3" />
      <el-table-column width="120" label="4日奖惩数量" align="center" prop="rpNum4" />
      <el-table-column width="120" label="5日奖惩数量" align="center" prop="rpNum5" />
      <el-table-column width="120" label="6日奖惩数量" align="center" prop="rpNum6" />
      <el-table-column width="120" label="7日奖惩数量" align="center" prop="rpNum7" />
      <el-table-column width="120" label="8日奖惩数量" align="center" prop="rpNum8" />
      <el-table-column width="120" label="9日奖惩数量" align="center" prop="rpNum9" />
      <el-table-column width="120" label="10日奖惩数量" align="center" prop="rpNum10" />
      <el-table-column width="120" label="11日奖惩数量" align="center" prop="rpNum11" />
      <el-table-column width="120" label="12日奖惩数量" align="center" prop="rpNum12" />
      <el-table-column width="120" label="13日奖惩数量" align="center" prop="rpNum13" />
      <el-table-column width="120" label="14日奖惩数量" align="center" prop="rpNum14" />
      <el-table-column width="120" label="15日奖惩数量" align="center" prop="rpNum15" />
      <el-table-column width="120" label="16日奖惩数量" align="center" prop="rpNum16" />
      <el-table-column width="120" label="17日奖惩数量" align="center" prop="rpNum17" />
      <el-table-column width="120" label="18日奖惩数量" align="center" prop="rpNum18" />
      <el-table-column width="120" label="19日奖惩数量" align="center" prop="rpNum19" />
      <el-table-column width="120" label="20日奖惩数量" align="center" prop="rpNum20" />
      <el-table-column width="120" label="21日奖惩数量" align="center" prop="rpNum21" />
      <el-table-column width="120" label="22日奖惩数量" align="center" prop="rpNum22" />
      <el-table-column width="120" label="23日奖惩数量" align="center" prop="rpNum23" />
      <el-table-column width="120" label="24日奖惩数量" align="center" prop="rpNum24" />
      <el-table-column width="120" label="25日奖惩数量" align="center" prop="rpNum25" />
      <el-table-column width="120" label="26日奖惩数量" align="center" prop="rpNum26" />
      <el-table-column width="120" label="27日奖惩数量" align="center" prop="rpNum27" />
      <el-table-column width="120" label="28日奖惩数量" align="center" prop="rpNum28" />
      <el-table-column width="120" label="29日奖惩数量" align="center" prop="rpNum29" />
      <el-table-column width="120" label="30日奖惩数量" align="center" prop="rpNum30" />
      <el-table-column width="120" label="31日奖惩数量" align="center" prop="rpNum31" />
      <el-table-column width="120" label="合计奖惩金额" align="center" prop="rePunPrice" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['hr:rePunAssess:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hr:rePunAssess:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改奖惩考核管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">

        <el-row>
          <el-col :span="8">
            <el-form-item label="计件年月" prop="jjYm">
              <el-date-picker clearable
                              v-model="form.jjYm"
                              type="month"
                              value-format="yyyy-MM"
                              placeholder="请选择计件年月">
              </el-date-picker>
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="工号" prop="jobNo">
              <el-input v-model="form.jobNo" placeholder="请选择员工" readonly>
                <el-button slot="append" icon="el-icon-search" @click="handleSelectPerson"></el-button>
              </el-input>
            </el-form-item>
            <PersonSelect ref="personSelect" @onSelected="onPersonSelected" ></PersonSelect>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="form.name" placeholder="请输入姓名" readonly/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="部门" prop="department">
              <el-input v-model="form.department" placeholder="请输入部门" readonly/>
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="分部" prop="branch">
              <el-input v-model="form.branch" placeholder="请输入分部" readonly/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="班组" prop="team">
              <el-input v-model="form.team" placeholder="请输入班组" readonly/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="岗位" prop="jobs">
              <el-input v-model="form.jobs" placeholder="请输入岗位" readonly/>
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="奖惩项目" prop="rePunProject">
              <el-input v-model="form.rePunProject" placeholder="请输入奖惩项目" >
                <el-button slot="append" icon="el-icon-search" @click="handleSelectProject"></el-button>
              </el-input>
            </el-form-item>
            <ProjectSelect ref="projectSelect" @onSelected="onProjectSelected" ></ProjectSelect>
          </el-col>
          <el-col :span="8">
            <el-form-item label="奖惩小项" prop="rePunPro">
              <el-input v-model="form.rePunPro" placeholder="请输入奖惩小项" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="奖惩标准" prop="rePunStandard">
              <el-input v-model="form.rePunStandard" placeholder="请输入奖惩标准" />
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="部门奖惩标准" prop="bmRePunStandard">
              <el-input v-model="form.bmRePunStandard" placeholder="请输入部门奖惩标准" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="分部奖惩标准" prop="fbRePunStandard">
              <el-input v-model="form.fbRePunStandard" placeholder="请输入分部奖惩标准" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="车间奖惩标准" prop="cjRePunStandard">
              <el-input v-model="form.cjRePunStandard" placeholder="请输入车间奖惩标准" />
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="班组奖惩标准" prop="bzRePunStandard">
              <el-input v-model="form.bzRePunStandard" placeholder="请输入班组奖惩标准" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="1日奖惩数量" prop="rpNum1">
              <el-input v-model="form.rpNum1" placeholder="请输入1日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="2日奖惩数量" prop="rpNum2">
              <el-input v-model="form.rpNum2" placeholder="请输入2日奖惩数量" />
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="3日奖惩数量" prop="rpNum3">
              <el-input v-model="form.rpNum3" placeholder="请输入3日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="4日奖惩数量" prop="rpNum4">
              <el-input v-model="form.rpNum4" placeholder="请输入4日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="5日奖惩数量" prop="rpNum5">
              <el-input v-model="form.rpNum5" placeholder="请输入5日奖惩数量" />
            </el-form-item>

          </el-col>
          <el-col :span="8">
            <el-form-item label="6日奖惩数量" prop="rpNum6">
              <el-input v-model="form.rpNum6" placeholder="请输入6日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="7日奖惩数量" prop="rpNum7">
              <el-input v-model="form.rpNum7" placeholder="请输入7日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="8日奖惩数量" prop="rpNum8">
              <el-input v-model="form.rpNum8" placeholder="请输入8日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="9日奖惩数量" prop="rpNum9">
              <el-input v-model="form.rpNum9" placeholder="请输入9日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="10日奖惩数量" prop="rpNum10">
              <el-input v-model="form.rpNum10" placeholder="请输入10日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="11日奖惩数量" prop="rpNum11">
              <el-input v-model="form.rpNum11" placeholder="请输入11日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="12日奖惩数量" prop="rpNum12">
              <el-input v-model="form.rpNum12" placeholder="请输入12日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="13日奖惩数量" prop="rpNum13">
              <el-input v-model="form.rpNum13" placeholder="请输入13日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="14日奖惩数量" prop="rpNum14">
              <el-input v-model="form.rpNum14" placeholder="请输入14日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="15日奖惩数量" prop="rpNum15">
              <el-input v-model="form.rpNum15" placeholder="请输入15日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="16日奖惩数量" prop="rpNum16">
              <el-input v-model="form.rpNum16" placeholder="请输入16日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="17日奖惩数量" prop="rpNum17">
              <el-input v-model="form.rpNum17" placeholder="请输入17日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="18日奖惩数量" prop="rpNum18">
              <el-input v-model="form.rpNum18" placeholder="请输入18日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="19日奖惩数量" prop="rpNum19">
              <el-input v-model="form.rpNum19" placeholder="请输入19日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="20日奖惩数量" prop="rpNum20">
              <el-input v-model="form.rpNum20" placeholder="请输入20日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="21日奖惩数量" prop="rpNum21">
              <el-input v-model="form.rpNum21" placeholder="请输入21日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="22日奖惩数量" prop="rpNum22">
              <el-input v-model="form.rpNum22" placeholder="请输入22日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>



        <el-row>
          <el-col :span="8">
            <el-form-item label="23日奖惩数量" prop="rpNum23">
              <el-input v-model="form.rpNum23" placeholder="请输入23日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="24日奖惩数量" prop="rpNum24">
              <el-input v-model="form.rpNum24" placeholder="请输入24日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="25日奖惩数量" prop="rpNum25">
              <el-input v-model="form.rpNum25" placeholder="请输入25日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="26日奖惩数量" prop="rpNum26">
              <el-input v-model="form.rpNum26" placeholder="请输入26日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="27日奖惩数量" prop="rpNum27">
              <el-input v-model="form.rpNum27" placeholder="请输入27日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="28日奖惩数量" prop="rpNum28">
              <el-input v-model="form.rpNum28" placeholder="请输入28日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="29日奖惩数量" prop="rpNum29">
              <el-input v-model="form.rpNum29" placeholder="请输入29日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="30日奖惩数量" prop="rpNum30">
              <el-input v-model="form.rpNum30" placeholder="请输入30日奖惩数量" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="31日奖惩数量" prop="rpNum31">
              <el-input v-model="form.rpNum31" placeholder="请输入31日奖惩数量" />
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="合计奖惩金额" prop="rePunPrice">
              <el-input v-model="form.rePunPrice" placeholder="请输入合计奖惩金额" />
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRePunAssess, getRePunAssess, delRePunAssess, addRePunAssess, updateRePunAssess } from "@/api/hr/rePunAssess";
import {getToken} from "@/utils/auth";
import PersonSelect from "@/components/personSelect";
import ProjectSelect from "@/components/punishmentSelect";

export default {
  name: "RePunAssess",
  components :{PersonSelect,ProjectSelect},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 奖惩考核管理表格数据
      rePunAssessList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        jjYm: null,
        factoryCode: null,
        factoryName: null,
        jobNo: null,
        name: null,
        department: null,
        branch: null,
        team: null,
        jobs: null,
        rePunProject: null,
        rePunPro: null,
        rePunStandard: null,
        bmRePunStandard: null,
        fbRePunStandard: null,
        cjRePunStandard: null,
        bzRePunStandard: null,
        rpNum1: null,
        rpNum2: null,
        rpNum3: null,
        rpNum4: null,
        rpNum5: null,
        rpNum6: null,
        rpNum7: null,
        rpNum8: null,
        rpNum9: null,
        rpNum10: null,
        rpNum11: null,
        rpNum12: null,
        rpNum13: null,
        rpNum14: null,
        rpNum15: null,
        rpNum16: null,
        rpNum17: null,
        rpNum18: null,
        rpNum19: null,
        rpNum20: null,
        rpNum21: null,
        rpNum22: null,
        rpNum23: null,
        rpNum24: null,
        rpNum25: null,
        rpNum26: null,
        rpNum27: null,
        rpNum28: null,
        rpNum29: null,
        rpNum30: null,
        rpNum31: null,
        rePunPrice: null,
      },
      // 表单参数
      form: {

      },
      //考勤导入
      upload: {
        // 是否显示弹出层（物料导入）
        open: false,
        // 弹出层标题（物料导入）
        title: "导入数据",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/hr/rePunAssess/importData"
      },
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  activated(){
    if(this.$route.query.jobNo){
      this.queryParams.jobNo = this.$route.query.jobNo
    }
    this.getList();
  },
  methods: {
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "原始数据";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('hr/rePunAssess/importTemplate', {
      }, `奖惩明细.xlsx`)
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 查询奖惩考核管理列表 */
    getList() {
      this.loading = true;
      listRePunAssess(this.queryParams).then(response => {
        this.rePunAssessList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        jjYm: null,
        factoryCode: null,
        factoryName: null,
        jobNo: null,
        name: null,
        department: null,
        branch: null,
        team: null,
        jobs: null,
        rePunProject: null,
        rePunPro: null,
        rePunStandard: null,
        bmRePunStandard: null,
        fbRePunStandard: null,
        cjRePunStandard: null,
        bzRePunStandard: null,
        rpNum1: 0,
        rpNum2: 0,
        rpNum3: 0,
        rpNum4: 0,
        rpNum5: 0,
        rpNum6: 0,
        rpNum7: 0,
        rpNum8: 0,
        rpNum9: 0,
        rpNum10: 0,
        rpNum11: 0,
        rpNum12: 0,
        rpNum13: 0,
        rpNum14: 0,
        rpNum15: 0,
        rpNum16: 0,
        rpNum17: 0,
        rpNum18: 0,
        rpNum19: 0,
        rpNum20: 0,
        rpNum21: 0,
        rpNum22: 0,
        rpNum23: 0,
        rpNum24: 0,
        rpNum25: 0,
        rpNum26: 0,
        rpNum27: 0,
        rpNum28: 0,
        rpNum29: 0,
        rpNum30: 0,
        rpNum31: 0,
        rePunPrice: 0,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加奖惩考核管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRePunAssess(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改奖惩考核管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRePunAssess(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRePunAssess(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除奖惩考核管理编号为"' + ids + '"的数据项？').then(function() {
        return delRePunAssess(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('hr/rePunAssess/export', {
        ...this.queryParams
      }, `rePunAssess_${new Date().getTime()}.xlsx`)
    },
    handleSelectPerson(){
      this.$refs.personSelect.showFlag = true;
    },
    onPersonSelected(obj){
      if(obj != undefined && obj != null){
        this.form.jobNo = obj.jobNo;
        this.form.name = obj.pname;
        this.form.department = obj.department;
        this.form.branch = obj.branch;
        this.form.team = obj.pgroup;
        this.form.jobs = obj.jobs;
      }
    },
    handleSelectProject(){
      this.$refs.projectSelect.showFlag = true;
    },
    onProjectSelected(obj){
      if(obj != undefined && obj != null){
        this.form.rePunProject = obj.rePunProject;
        this.form.rePunPro = obj.rePunPro;
        this.form.rePunStandard = obj.rePunStandard;
        this.form.bmRePunStandard = obj.bmRePunStandard;
        this.form.fbRePunStandard = obj.fbRePunStandard;
        this.form.cjRePunStandard = obj.cjRePunStandard;
        this.form.bzRePunStandard = obj.bzRePunStandard;
      }
    },
  }
};
</script>
